<!--
 * new page
 * @author: xuaolei
 * @since: 2022-08-25
 * AlbumList.vue
-->
<script setup lang="ts">
const props = defineProps({
  albumList: Array<any>,
  num: Number,
  loading: Boolean,
});
</script>

<template>
  <el-skeleton :loading="loading" animated :count="num" :throttle="500">
    <template #template>
      <div class="item">
        <el-skeleton-item class="ske-img" variant="image" />
        <div class="ske-info">
          <el-skeleton-item variant="h3" class="ske-name" />
          <el-skeleton-item variant="h3" class="ske-name" style="width: 50%" />
          <el-skeleton-item variant="text" class="ske-txt" />
        </div>
      </div>
    </template>
    <template #default>
      <div class="album">
        <router-link
          :to="{ path: '/album', query: { id: item.id } }"
          class="item"
          :key="item.id"
          v-for="item in albumList"
        >
          <el-image :src="item.picUrl + '?param=120y120'" lazy>
            <div slot="placeholder" class="image-slot">
              <i class="iconfont icon-placeholder"></i>
            </div>
          </el-image>
          <div class="info">
            <div class="album-type">{{ item.type }}</div>
            <h2 class="album-name" v-if="item.name">{{ item.name }}</h2>
            <div class="artist-name" v-if="item.artist">
              {{ item.artist.name }}
            </div>
          </div>
        </router-link>
      </div>
    </template>
  </el-skeleton>
</template>

<style scoped lang="scss">
.album {
  display: flex;
  flex-wrap: wrap;
  flex-direction: row;
  justify-content: left;
  align-items: center;
  padding-bottom: 20px;
  margin: 0 -10px;

  .item {
    display: flex;
    flex: 25%;
    max-width: calc(100% / 3 - 20px);
    margin: 0px 10px 20px;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--el-bg-color-page);
    align-items: center;
    &:hover {
      box-shadow: 0 5px 1em 0px var(--el-color-info-light-7);
      background-color: var(--el-bg-color-page);
      transform: translateY(-3px);
      transition: all 0.3s ease-in-out;
      .album-name {
        color: var(--el-text-color-primary);
      }
    }
  }

  .el-image {
    border-radius: 4px;
    z-index: 2;
    height: 80px;
    width: 80px;
  }

  .info {
    position: relative;
    min-height: 80px;
    max-height: 120px;
    flex: 3;
    margin-left: 20px;
    overflow: hidden;
    color: var(--el-color-white);

    .album-name {
      padding: 7% 20px 10px 0;
      font-size: var(--el-font-size-base);
      color: var(--el-text-color-primary);
      word-break: break-all;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .artist-name {
      font-size: var(--el-font-size-base);
      color: var(--el-text-color-primary);
    }

    .album-type {
      position: absolute;
      top: 8px;
      right: -30px;
      width: 100px;
      line-height: 24px;
      font-size: 12px;
      transform: rotate(45deg);
      text-align: center;
      color: var(---el-color-white);
      background-color: var(--el-color-primary);
    }
  }
}

.el-skeleton {
  display: flex;
  width: auto;
  flex-wrap: wrap;
  flex-direction: row;
  justify-content: left;
  padding-bottom: 40px;
  margin: 0 -10px;
  font-size: 0;

  .item {
    display: flex;
    flex: 25%;
    max-width: calc(100% / 4 - 20px);
    margin: 20px 10px 0;
  }

  .ske-img {
    display: block;
    position: relative;
    width: 120px;
    height: 120px;
    line-height: 150px;
    text-align: center;
  }

  .ske-info {
    position: relative;
    flex: 1;
    margin: 5% 0 0 10%;
    overflow: hidden;
  }

  .ske-name {
    margin: 5px 0;
  }

  .ske-txt {
    display: block;
    margin-top: 10px;
    width: 10%;
  }
}
</style>
